/**
 * 
 */
package com.ucpaas.sms.service.smsAudit;

import com.jsmsframework.audit.enums.AuditPage;
import com.jsmsframework.audit.util.DFAUtil4AuditUtil;
import com.jsmsframework.common.dto.JsmsPage;
import com.jsmsframework.common.dto.ResultVO;
import com.ucpaas.sms.entity.message.TestAccount;
import com.ucpaas.sms.enums.AuditPageName;
import com.ucpaas.sms.model.PageContainer;
import org.springframework.context.annotation.Description;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;

/**
 * 短信审核
 */
public interface SmsAuditService {

	/**
	 *  缓存客户对应的关键字树，当修改关键字列表、类别、组别、用户配置时，需失效此缓存
	 * @param clientId
	 * @return
	 */
    void disableCache(String clientId);

	/**
	 * 缓存客户对应的关键字树，当修改关键字列表、类别、组别、用户配置时，需失效此缓存
	 */
	void disableCache();

    List<String> doDisable(String clientId);

    /**
	 *  缓存客户对应的关键字树，当修改关键字列表、类别、组别、用户配置时，需失效此缓存
	 *  自带刷新
	 * @param clientIds
	 * @return
	 */
    void disableCache(List<String> clientIds);


	/**
	 *  缓存客户对应的关键字树，当修改关键字列表、类别、组别、用户配置时，需失效此缓存
	 * @param clientIds
	 * @return
	 */
	void disableCacheNoRefresh(List<String> clientIds);
	/**
	 * 短信审核查询页面
	 * @param params
	 * @return
	 */
	PageContainer auditQueryPage(Map<String, String> params);

	/**
	 * 短信审核页面
	 * @param params
	 * @param kind -> AuditPageName YZM_NUM | MAJOR_NUM | ORDINARY_NUM
	 * @return
	 */
//	List<Map<String, Object>> auditPage(String smsType,AuditPageName kind);
	List<Map<String, Object>> auditPage(Map<String, String> params,AuditPageName kind,AuditPage auditPage);

    DFAUtil4AuditUtil.DFANode4Audit<String> putClientAuditKeywordAndCategoryInCahche(String clientid);

    /**
	 * 获取所有的测试账号
	 * @return List<TestAccount>
	 */
	List<TestAccount> getTestClientid(Map params);

	/**
	 * 更新短信审核状态
	 * @param params   （auditIds/status/userId/transferToId/remark）
	 * @return
	 */
	Map<String, Object> updateStatus(Map<String, String> params) throws Exception;

    @Transactional("message_new")
    Map<String, Object> facadeUpdateStatus(Map<String, String> params, AuditPageName auditPageName);

    Map<String, Object> updateStatus(Map<String, String> params, AuditPageName auditPageName) throws Exception;

	ResultVO testSendAction(Map<String, String> params);

	@Deprecated
	@Description("由于展示的记录数不准确所以废弃，采用带参数的getNeedAuditNum方法")
	Map<String, Object> getKindsAuditNum();

	/**
	 * 查询各个级别的待审核记录数、已锁定记录数、待发送记录数
	 * @param recordCount
	 * @param auditPageName
	 * @return
	 */
	Map<String,Object> getKindsAuditNum(String recordCount, String auditPageName);


    @Scheduled(cron = "0/10 * * * * ?") // 15秒执行一次
    void refreshDFATreeCache();

    Map<String, DFAUtil4AuditUtil.DFANode4Audit<String>> getDfaTreeCache();

	Map<String, Map<String, Object>> getAuditCache();

	void updateKindsAuditNum();

	void cacheKindsAuditId();

	/**
	 * 查询短信审核超时时间
	 * @return
	 */
	Map<String, Object> getAuditExpireTime();

	/**
	 * 查询待审核记录数
	 * @return
	 */
	Map<String, Object> getNeedAuditNum();



	/**
	 * 短信历史审核查询
	 * @param page
	 * @return
	 */
	JsmsPage hisauditQueryPage(JsmsPage page);
	/**
	 * 短信历史备份库审核查询
	 * @param page
	 * @return
	 */
	JsmsPage hisbakauditQueryPage(JsmsPage page);


	/**
	 * 查询历史审核记录
	 * @param params
	 * @return
	 */
	List<Map<String ,Object>> queryhisAll(Map<String,String> params);

	/**
	 * 查询历史审核记录
	 * @param params
	 * @return
	 */
	List<Map<String ,Object>> queryhisbakAll(Map<String,String> params);


	/**
	 * 设置审核过期
	 * @param auditId
	 * @return
	 */
	Map<String, Object> setAuditExpired(String auditId) throws Exception;

    AudtiResultMQConfiguration getAudtiResultMQConfiguration();

    /**
	 * 设置MQ信息
	 * @param audtiResultMQConfiguration
	 */
	void setAudtiResultMQConfiguration(AudtiResultMQConfiguration audtiResultMQConfiguration) throws IOException, TimeoutException;

}
